import request from './request'

// 字典类型API
export function getDictTypes() {
  return request({ url: '/api/dict/types', method: 'get' })
}
export function createDictType(data) {
  return request({ url: '/api/dict/types', method: 'post', data })
}
export function updateDictType(id, data) {
  return request({ url: `/api/dict/types/${id}`, method: 'put', data })
}
export function deleteDictType(id) {
  return request({ url: `/api/dict/types/${id}`, method: 'delete' })
}

// 导出字典类型Excel
export function exportDictTypesExcel() {
  return request({ url: '/api/dict/types/export/excel', method: 'get', responseType: 'blob' })
}

// 字典项API
export function getDictItems(type_code) {
  return request({ url: '/api/dict/items', method: 'get', params: { type_code } })
}
export function createDictItem(data) {
  return request({ url: '/api/dict/items', method: 'post', data })
}
export function updateDictItem(id, data) {
  return request({ url: `/api/dict/items/${id}`, method: 'put', data })
}
export function deleteDictItem(id) {
  return request({ url: `/api/dict/items/${id}`, method: 'delete' })
}

// 通过类型编码获取字典项（下拉专用）
export function getDictItemsByCode(code) {
  return request({ url: `/api/dict/items/by_code/${code}`, method: 'get' })
}

// 导出字典项Excel
export function exportDictItemsExcel(params) {
  return request({ url: '/api/dict/items/export/excel', method: 'get', params, responseType: 'blob' })
} 